<?php
	$all_selection = substr($_POST['SelectedPayments'],0,strlen($_POST['SelectedPayments'])-1);
	if($all_selection ==''){die('<div class=Error>Sem valores a pagamento.</div>');}
	$prStr = '<div id=printRemittancePayment name=printRemittancePayment style="margin-bottom:20px;height:500px;display:none">
	<div style="margin:3px;padding:3px;background-color:#CFCFCF"><b>Tuga Report - Serviço de Transferencias - Transmissoes de Dominio</b><br>Validado a: '.$sysTime.'<br>Validado por: <b>'.$_SESSION[$SESSID].'</b>
	</div><table style="width:100%">';
	$GET = $GLOBALS['MYT']->db_array("SELECT FraID,FraFechaIngreso,FraAlbaran,
  FraUrgente,FraARecibir,FraEnviado,FraCargo,FraTasa,FraBnfNombre,sg_Abreviatura AS FraStatus, FraModo,
  FraBnfDocType,FraBnfCedula,FraBancoID,FraCiudadSucursal,FraSucursal,FraTipoCuenta,FraCuenta
   FROM facturas
   INNER JOIN facturasextjoins ON FraID = FraExtID
   INNER JOIN facturas_income ON FraIncID = FraID
   INNER JOIN hd_statusfacturas ON sg_ID = FraStatus
   LEFT OUTER JOIN hd_bancos ON bp_Country = FraClPais AND bp_Name = FraBancoID
   WHERE FraModo = 2 AND FraModoPago = 1 AND FraAlbaran > 0 AND FraNumero = 0 AND FraStatus = 16 AND FraID IN ($all_selection)");

	$CGET = $GET[0];
		$TTotal = 0;
		$TSent = 0;
		$TPay = 0;

	for($i=1;$i<=$CGET;$i++){
		$TTotal += $GET[$i]['FraARecibir'];
		$TSent += $GET[$i]['FraEnviado'];
		$TPay += $GET[$i]['FraARecibir'];

		$prStr .= '<tr><td colspan="10"><hr style="width:100%;size:1" /></td>
			<tr><td colspan="3">Dominio: </b></td><td colspan="3">Data da comunicacao: '.$GET[$i]['tdm_Date'].', por: '.$GET[$i]['username'].'</td></tr>
			<tr><td colspan="7">Observ: '.$GET[$i]['tdm_Description'].'</td></tr>

			<tr><td>Operacao</td><td>Canal</td>
                        <td>Destinatario</td><td>Banco Pagamento</td><td>Numero de Conta</td>
                        <td>A Pagar</td><td>Data</td><td>Estado</td>
                        </tr>
			<tr><td>'.$GET[$g]['FraID'].'</td>
                            <td>'.$_colmodo[$GET[$g]['FraModo']].'</td>
                                <td>'.$GET[$g]['FraBnfNombre'].'</td>
                                    <td>'.$GET[$g]['FraBancoID'].'</td>
                                        <td>'.$GET[$g]['FraCuenta'].'</td>
                                            <td>'.number_format($GET[$g]['FraARecibir'], 2, '.', '').'</td>
                                                <td>'.$GET[$g]['FraFechaIngreso'].'</td>
                                                <td>'.$GET[$g]['FraStatus'].'</td></tr>';
	}
		$prStr .= '<tr><td colspan="10"><hr style="width:100%;size:1" /></td>
			<tr><td colspan="3"></td><td colspan="3"></td></tr>
			<tr><td colspan="7"></td></tr>
			<tr><td>Remessas</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
			<tr><td># '.$TTotal.'</td><td></td><td>Total Enviado: '.number_format($TSent,2,',','.').'</td><td>Total Pagar: '.number_format($TPay,2,',','.').'</td><td></td><td></td><td></td></tr>';

	$prStr .= '</table>

        <p>
</div>
	<script charset="utf-8" type="text/javascript">printdiv(\'printRemittancePayment\');</script>';
	echo $prStr;
